package object;

/**
 * 重写了从Object 继承的、可见的 toString 方法 （同名、同参、同返回）
 */
public class Loong {
    private String name;
    private int age;

    public Loong(String name,int age){
        this.name = name;
        this.age = age;
    }

    public String toString(){
        //System.out.println(this.name + " , " + this.age);
        String x = this.name + " , " + this.age;
        return x;
    }

    public static void main(String[] args) {
        Loong o = null;
        System.out.println( o );
        // System.out.println( o.toString() ) ; // java.lang.NullPointerException

        o = new Loong("敖丙",20);
        System.out.println( o );
        System.out.println( o .toString());
    }
}
